﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MvcJ.Models
{
    [System.Web.Mvc.Bind(Exclude = "ID")]
    public class SimpleModel
    { 
        public int ID { get; set; }
        public string Name { get; set; }
        public string Comment { get; set; }
    } 

    public class SimpleService
    {
        private static IList<SimpleModel> models = new List<SimpleModel>();
        private static int index = 0;
        public IList<SimpleModel> ListModels()
        {
            return models;
        }

        public void SaveModel(SimpleModel model)
        {
            model.ID = index++;
            models.Add(model);
        }

        public void DeleteModel(int id)
        {
           var m= models.First( c => c.ID == id);
           if (m != null)
               models.Remove(m);
        }
    }
}
